package com.yang.service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yang.mapper.ProviderMapper;
import com.yang.pojo.Provider;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class ProviderServiceImpl implements ProviderService {
    @Autowired
    private ProviderMapper providerMapper;

    public void setProviderMapper(ProviderMapper providerMapper) {
        this.providerMapper = providerMapper;
    }

    public PageInfo<Provider> queryByCodeAndName(Provider provider, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Provider> providers = providerMapper.queryByCodeAndName(provider);
        return new PageInfo<Provider>(providers);
    }

    public List<Provider> queryAll() {
        return providerMapper.queryAll();
    }

    public Provider queryById(Integer id) {
        return providerMapper.queryById(id);
    }

    public Integer delete(Integer id) {
        return providerMapper.delete(id);
    }

    public List<Provider> queryByCode(String code) {
        return providerMapper.queryByCode(code);
    }

    public Integer addProvider(Provider provider) {
        return providerMapper.addProvider(provider);
    }

    public Integer update(Provider provider) {
        return providerMapper.update(provider);
    }
}
